/*
============================================================================
FileName	:	XQChatTalkGroup.cpp
Author		:	liyake
Website		:	http://www.liyake.com
Create Data	:	2012-03-08 13:07
Change Data	:	2012-03-08 13:07
Detail		:	The chat dialog of xqchat application
============================================================================
*/
#include "XQChatTalkNode.h"
#include <QtGui>

XQChat::CXQChatTalkNode::CXQChatTalkNode( QGraphicsItem* parent /*= 0*/ )
	: QGraphicsObject(parent)
{
	setFlag(ItemIsMovable);
	setFlag(ItemSendsGeometryChanges);
	setCacheMode(DeviceCoordinateCache);
	setZValue(-3);

	QWidget* pTab = new QWidget();
	QVBoxLayout* pLayout = new QVBoxLayout();
	QTextBrowser* pTextBrowser = new QTextBrowser();
	QLineEdit* pLineEdit = new QLineEdit("test");
	pTextBrowser->setText("Show talk history here.");

	pLayout->addWidget(pTextBrowser);
	pLayout->addWidget(pLineEdit);
	pTab->setLayout(pLayout);

	pTab->setFixedSize(200,200);

	QGraphicsProxyWidget* pWidget = new QGraphicsProxyWidget(this);
	pWidget->setWidget(pTab);
}

XQChat::CXQChatTalkNode::~CXQChatTalkNode(void)
{

}

QRectF XQChat::CXQChatTalkNode::boundingRect() const
{
	return QRectF(0,0,200,200);
}

void XQChat::CXQChatTalkNode::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget /*= 0 */ )
{
	painter->save();
	painter->fillRect(option->rect,Qt::red);
	painter->restore();
}

void XQChat::CXQChatTalkNode::mouseMoveEvent( QGraphicsSceneMouseEvent* event )
{
	//QRectF rtClient = mapRectToParent(boundingRect());
	//QGraphicsItem* pItemParent = parentItem();
	//if(pItemParent->boundingRect().contains(rtClient.topLeft())&&
	//	pItemParent->boundingRect().contains(rtClient.bottomRight()))
	//{
	//	return QGraphicsObject::mouseMoveEvent(event);
	//}
	return QGraphicsObject::mouseMoveEvent(event);
}
